<?php
header("Content-Type: text/html;charset=utf-8"); 
require_once('../Core/medoo.php');

$db = new medoo(
    array(
    'database_type' => 'mysql',
	/*数据库名*/
    'database_name' => 'kyomini',
    'server' => 'localhost',
	/*数据库用户名*/
    'username' => 'root',
	/*数据库密码*/
    'password' => 'root',
    'port' => 3306,
    'charset' => 'utf8',
	));



  $page=isset($_GET['page'])?intval($_GET['page']):1;       
  $num=5;        

  $total=$db->count("article"); 
  $pagenum=ceil($total/$num);    

  if($page>$pagenum || $page == 0){
	 echo "Error : Can Not Found The page .";
	 exit;
  }

  $offset=($page-1)*$num;       
  $info=$db->select("article", array(
	  "title",
	  "id",),
	   array(
	   "ORDER" => "id DESC",
	   "LIMIT" => array($offset,$num)
  ));
													  
  
  foreach($info as $data){
	  echo "<li>id:" . $data["id"] . " 标题 :<a href='edit.php?=".$data["id"]. "'>".$data["title"].      "</a></li>";
  }
  

  for($i=1;$i<=$pagenum;$i++){
		 $show=($i!=$page)?"<a href='page.php?page=".$i."'>$i</a>":"<b>$i</b>";
		 echo $show." ";
  }


?>

